package juego

import org.uqbar.arena.windows.SimpleWindow
import org.uqbar.arena.windows.WindowOwner
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.List
import model.AppModel.ExpedientesAppModel
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.bindings.PropertyAdapter
import unq.model.Villano
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.commons.utils.Observable
import org.uqbar.arena.widgets.Button

@Observable
class VistaExpedientesWindow extends SimpleWindow<ExpedientesAppModel> {
	
	new(WindowOwner parent, ExpedientesAppModel model) {
		super(parent, model)
		title = "Expedientes"
	}
	
	override protected addActions(Panel actionsPanel) {
	new Button(actionsPanel) => [
		caption = " cerrar expedientes"
		onClick = [|close]
	]
	}
		def PanelDescripcion(Panel panel, String textm, String propiedad) {
		new Label(panel) => [text = textm fontSize = 13]
		new List(panel) => [
			bindItemsToProperty(propiedad)
			width = 150
			heigth = 50
		]
	
}
	
		def crearPanelLista(Panel panel) {
		new Panel(panel) => [
			setLayout(new VerticalLayout())
			new Label(it) => [text = "Villanos" fontSize = 13]
			new List(it) => [
				val binding = bindItemsToProperty("juego.listaVillanos")
				binding.setAdapter(new PropertyAdapter(Villano, "nombre"))
				bindValueToProperty("villanoSeleccionado")
				width = 150
				heigth = 50
			]
		]

	}
		
		def crearPanelDescripcionSelecion(Panel panel) {
		new Panel(panel) => [
			setLayout(new VerticalLayout())
			PanelDescripcion(it, "seniasParticulares", "villanoSeleccionado.seniasParticulares")
			PanelDescripcion(it, "hobbies", "villanoSeleccionado.hobbies")
		]

	}

override protected createFormPanel(Panel mainPanel) {
		new Panel(mainPanel) => [
			setLayout(new ColumnLayout(2)) 
			crearPanelLista(it)
			crearPanelDescripcionSelecion(it)
			]
	}
}